import { GetCurrent } from '@/api/modules/loginApi'

/**
 * @name: user
 * @author: XU>.<CHEN
 * @date: 2023-01-28 14:24
 * @description：user
 * @update: 2023-01-28 14:24
 */

export default {
  namespaced: true,
  state: {
    userInfo: {}
  },
  getters: {

  },
  mutations: {
    setUser: function(state: any, userInfo: any) {
      state.userInfo = userInfo
    },
    removeUser: function(state: any) {
      state.userInfo = {}
    }
  },
  actions: {
    getCurrent({ commit }: any) {
      return new Promise((resolve, reject) => {
        GetCurrent().then(res => {
          commit('setUser', res)
          resolve(res)
        })
      })
    }
  }
}
